<!DOCTYPE html>
<html lang="zh">

<head>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>页面</title>
    <script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/loading.js"></script>
    <link href="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/lib/theme-chalk/index.css" rel="stylesheet">
</head>

<body>
<div id="app">
    <el-container>
        <el-header>
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">合作商管理</el-breadcrumb-item>
                <el-breadcrumb-item>合同列表</el-breadcrumb-item>
                <el-breadcrumb-item>合同信息查看</el-breadcrumb-item>
            </el-breadcrumb>
        </el-header>
        <el-main>
            <el-form label-width="120px">
                <el-row>
                    <el-col>
                        <el-steps :active="1" simple>
                            <el-step title="合同信息" icon="el-icon-info" style="margin-left:-8%"></el-step>
                        </el-steps>
                    </el-col>
                </el-row>
                <br>
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="合同编号" prop="">
                            <el-input :disabled="true" v-model="contractForm.contract_no"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="合同名称" prop="contract_name">
                            <el-input :disabled="true" v-model="contractForm.contract_name"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="甲方名称" prop="partyA">
                            <el-input :disabled="true" v-model="contractForm.partyA"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="乙方名称" prop="partyB">
                            <el-select :disabled="true" v-model="contractForm.partyB" filterable placeholder="请选择"
                                       style="width: 100%">
                                <el-option v-for="item in options" :key="item.id" :label="item.company_name"
                                           :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="预计合同金额" prop="contract_price">
                            <el-input :disabled="true" v-model="contractForm.contract_price"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="有效时间" prop="active_time">
                            <el-date-picker :disabled="true" value-format="yyyy-MM-dd"
                                            v-model="contractForm.active_time" type="date" placeholder="选择日期"
                                            style="width:100%">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="结束时间" prop="end_time">
                            <el-date-picker :disabled="true" value-format="yyyy-MM-dd" v-model="contractForm.end_time"
                                            type="date" placeholder="选择日期" style="width:100%">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="付款说明" prop="payment">
                            <el-input :disabled="true" type="textarea" v-model="contractForm.payment"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="合同说明" prop="contract_note">
                            <el-input :disabled="true" type="textarea" v-model="contractForm.contract_note"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col>
                        <el-steps :active="1" simple>
                            <el-step title="SKU清单" icon="el-icon-info" style="margin-left:-8%"></el-step>
                        </el-steps>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="12" :sm="12" :md="8" :lg="8" :xl="8">
                        <el-input placeholder="请输入内容" @keyup.enter.native="enterSearch" v-model="keySearch"
                                  style="width: 100%;margin-top: 12px">
                            <el-button slot="append" icon="el-icon-search" @click=search></el-button>
                        </el-input>
                    </el-col>

                </el-row>
                <el-table v-loading="tableLoading" :data="tableData" class="tb-edit" style="width: 100%" highlight-current-row
                          size="mini" tooltip-effect="dark" border>
                    <el-table-column label="序号"
                                     type="index"
                                     width="50" height="calc(100vh - 428px)">
                    </el-table-column>
                    <el-table-column label="材料编码" prop="sku_code" :show-overflow-tooltip=true>
                    </el-table-column>
                    <el-table-column label="材料名称" prop="sku_name" :show-overflow-tooltip=true>
                    </el-table-column>
                    <el-table-column label="品牌" prop="sku_brand" :show-overflow-tooltip=true>
                    </el-table-column>
                    <el-table-column label="单位" prop="sku_unit" :show-overflow-tooltip=true>
                    </el-table-column>
                    <el-table-column label="规格参数" prop="sku_slug_set" :show-overflow-tooltip=true>
                    </el-table-column>
                    <el-table-column label="型号" prop="sku_model" :show-overflow-tooltip=true>
                    </el-table-column>
                    <el-table-column label="销售价格" prop="sku_contract_price">
                    </el-table-column>
                </el-table>
                <el-row>
                    <el-col>
                        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                                       :page-sizes="[100, 500, 1000]"
                                       :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
                                       :total="totalRecords">
                        </el-pagination>
                    </el-col>
                </el-row>
                <br>

                <el-row>
                    <el-form-item>
                        <a href="/contract/list.page">
                            <el-button>返回</el-button>
                        </a>
                    </el-form-item>
                </el-row>
            </el-form>
        </el-main>
    </el-container>
</div>

<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/dist/vue.js"></script>
<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/lib/index.js"></script>
<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/publiccss/assets/global/plugins/jquery.min.js"
        type="text/javascript"></script>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                tableLoading: false,
                contractForm: {
                    id: '',
                    active_time: '',
                    companyB_id: "",
                    companyA_id: 1,
                    contract_name: "",
                    contract_price: "",
                    contract_note: "",
                    end_time: "",
                    payment: "",
                    tablePrice_id: "",
                    partyB: "",
                    partyA: '上海品宅装饰科技有限公司',
                },
                currentPage: 1, //当前页
                pageSize: 100, //每页总数
                totalRecords: 0, //总条数
                keySearch: '',
            }
        },
        methods: {
            //回车监听事件获取输入内容
            enterSearch: function (event) {
                this.currentPage = 1;
                this.pageSize = 100;
                this.keySearch = event.target.value;
                this.ajaxFunction()
            },
            //点击事件获取输入内容
            search: function () {
                this.currentPage = 1;
                this.pageSize = 100;
                this.ajaxFunction()
            },
            handleSizeChange: function (val) {
                this.pageSize = val;
                this.ajaxFunction()
            },
            handleCurrentChange: function (val) {
                this.currentPage = val;
                this.ajaxFunction()
            },
            ajaxFunction() {
                $.ajax({
                    url: '/contract/queryContractSummary.json?id=' + this.contractForm.id,
                    type: 'get',
                    dataType: 'json',
                    success: (result) => {
                        if (result.ret) {
                            this.contractForm = result.data;
                            this.skuInfoList();
                        } else {
                            this.$message.error('请求异常');
                        }
                    }
                });
            },
            skuInfoList() {
                this.tableLoading = true;
                $.ajax({
                    url: '/contract/contractSummaryDetailList.json',
                    type: 'get',
                    data: {
                        contract_id: this.contractForm.id,
                        key: this.keySearch,
                        page: this.currentPage,
                        limit: this.pageSize,
                    },
                    dataType: 'json',
                    success: (result) => {
                        this.tableLoading = false;
                        console.log(result);
                        if (result.ret) {

                            this.tableData = result.data;
                            this.totalRecords = result.count;
                        } else {
                            this.$message.error('请求异常');
                        }
                    }
                });
            },
        },
        mounted() {
            this.contractForm.id = '${id}';
            this.ajaxFunction();
        },
    })
</script>

</body>

</html>